<?php

namespace Acme\Likipe\BlogBundle\Entity;

use Doctrine\Common\Collections\ArrayCollection;

use Doctrine\ORM\Mapping as ORM;

/**
 * Acme\Likipe\BlogBundle\Entity\Categories
 *
 * @ORM\Table(name="category")
 * @ORM\Entity
 */
class Category
{
    /**
     * @var integer $id
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

    
    /**
     * @var string $name
     *
     * @ORM\Column(name="name", type="string", length=255)
     */
    private $name;
    
    
    /**
     * @ORM\ManyToOne(targetEntity="category", inversedBy="childen")
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
     */
    protected $parent;
    
    
    /**
     * @ORM\ManyToMany(targetEntity="Post", mappedBy="category")
     */
    protected $posts;
    
    
    /**
     * @ORM\OneToMany(targetEntity="Category", mappedBy="parent")
     */
    protected $childen;
    
    public function __construct()
    {
        $this->posts = new \Doctrine\Common\Collections\ArrayCollection();
    $this->childen = new \Doctrine\Common\Collections\ArrayCollection();
    }
    
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     */
    public function setName($name)
    {
        $this->name = $name;
    }

    /**
     * Get name
     *
     * @return string 
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set parent
     *
     * @param Acme\Likipe\BlogBundle\Entity\category $parent
     */
    public function setParent(\Acme\Likipe\BlogBundle\Entity\Category $parent)
    {
        $this->parent = $parent;
    }

    /**
     * Get parent
     *
     * @return Acme\Likipe\BlogBundle\Entity\category 
     */
    public function getParent()
    {
        return $this->parent;
    }

    /**
     * Add posts
     *
     * @param Acme\Likipe\BlogBundle\Entity\Post $posts
     */
    public function addPost(\Acme\Likipe\BlogBundle\Entity\Post $posts)
    {
        $this->posts[] = $posts;
    }

    /**
     * Get posts
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getPosts()
    {
        return $this->posts;
    }

    /**
     * Add childen
     *
     * @param Acme\Likipe\BlogBundle\Entity\Category $childen
     */
    public function addCategory(\Acme\Likipe\BlogBundle\Entity\Category $childen)
    {
        $this->childen[] = $childen;
    }

    /**
     * Get childen
     *
     * @return Doctrine\Common\Collections\Collection 
     */
    public function getChilden()
    {
        return $this->childen;
    }
}